import {createStore, applyMiddleware} from "redux";
import thunk from 'redux-thunk'
import reducers from './reducers/index.js'

/**
 * 自定义中间件logger
 * @param store
 * @returns {function(*): function(*=): *}
 */
const logger = store => next => action => {
  if (typeof action === 'object') {
    // console.log('dispatching a object ',action)
  } else {
    // console.log('dispatching not a object ', action)
  }
  const res = next(action);
  // console.log('nextState ',store.getState());
  store.getState();
  return res
};

const middlewares = [logger,thunk];

export default createStore(reducers, applyMiddleware(...middlewares));